package com.web.base.log.service;

import com.blue.jdbc.JdbcDataSource;
import com.blue.jdbc.Page;
import com.web.base.log.dao.UploadDao;
import com.web.base.log.model.Upload;
import com.web.core.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 上传文件日志业务层
 * 
 * @author 代码由 blue-code 框架生成
 * @since 1.0 2017年11月21日
 */
@Service("logUploadService")
@Transactional
@JdbcDataSource(Const.DS_BASE)
public class UploadService
{
	@Autowired
	private UploadDao uploadDao;
	
	public UploadService()
	{
	}
	
	public Upload save(Upload upload)
	{
		if (upload.getId() == null)
		{
			uploadDao.save(upload);
		}
		else
		{
			uploadDao.update(upload);
		}
		Upload a = uploadDao.get(upload.getId());
		return a;
	}
	
	public Upload get(Integer id)
	{
		Upload upload = uploadDao.get(id);
		return upload;
	}
	
	public Page<Upload> list(Upload upload, Page<Upload> page)
	{
		page = uploadDao.list(upload, page);
		return page;
	}
	
	public List<Upload> list(Upload upload)
	{
		List<Upload> list = uploadDao.list(upload);
		return list;
	}
	
	public void delete(Upload upload)
	{
		uploadDao.delete(upload);
	}
	
}
